package com.test.daily.leetcode.y2021.m11.day1113;

/**
 * @descriptions: detectCapitalUse
 * @author: Tom
 * @date: 2021/11/13 下午 09:24
 * @version: 1.0
 */
public class Code01_DetectCapitalUse {
    public static void main(String[] args) {

    }
    public boolean detectCapitalUse(String word) {
        if(word.charAt(0) >= 'A' && word.charAt(0) <= 'Z'){
            if(word.length() >= 2){
                if(word.charAt(1) >= 'A' && word.charAt(1) <= 'Z'){
                    for(int i = 2; i < word.length(); i++){
                        if(!(word.charAt(i) >= 'A' && word.charAt(i) <= 'Z')){
                            return false;
                        }
                    }
                } else {
                    for(int i = 2; i < word.length(); i++){
                        if(!(word.charAt(i) >= 'a' && word.charAt(i) <= 'z')){
                            return false;
                        }
                    }
                }
            }

        } else {
            for(int i = 1; i < word.length(); i++){
                if(!(word.charAt(i) >= 'a' && word.charAt(i) <= 'z')){
                    return false;
                }
            }
        }
        return true;
    }
}
